import os
import django

# 在environ字典里设置默认Django环境，'xxxx.settings'指Django项目的配置文件
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()

if __name__ == '__main__':
    # 创建租户
    # from plugins.dvadmin_tenant_backend.backend.models import Client, Domain
    # # create your public tenant
    # tenant = Client(schema_name='public',
    #                 name='Schemas Inc.',
    #                 paid_until='2016-12-05',
    #                 on_trial=True)
    # tenant.save()
    #
    # # Add one or more domains for the tenant
    # domain = Domain()
    # domain.domain = 'public.kfm168.com' # don't add your port or www here! on a local server you'll want to use localhost here
    # domain.tenant = tenant
    # domain.is_primary = True
    # domain.save()

    from plugins.dvadmin_tenant_backend.models import Client, Domain
    # create your public tenant
    tenant = Client(schema_name='demo',
                    name='demo',
                    paid_until='2016-12-05',
                    on_trial=True)
    tenant.save()

    # Add one or more domains for the tenant
    domain = Domain()
    domain.domain = 'demo.kfm168.com' # don't add your port or www here! on a local server you'll want to use localhost here
    domain.tenant = tenant
    domain.is_primary = True
    domain.save()


    # print('创建PaaS')
    # tenant, created = Client.objects.get_or_create(schema_name='public111',
    #                                                name='测试',
    #                                                paid_until='2020-12-05',on_trial=True)
    # tenant.save()
    #
    # print('append paas.anthembj.com to public tenant')
    # domain, _ = Domain.objects.get_or_create(domain = 'public.kfm168.com', tenant = tenant, is_primary = True)
    # domain.save()
